<?php

namespace App\Http\Controllers;

use App\Assorts;
use App\Boxs;
use App\Goods;
use Carbon\Carbon;
use Illuminate\Http\Request;

use App\Http\Requests;

class StatisticalController extends Controller
{
    public function total()
    {
        $totalsell = Assorts::where('state','7')->count();
        $totalamount = Assorts::where('state','7')->sum('discount');
        $totalbox = Boxs::count();
        $currentbox = Boxs::where('state','>','2')->whereRaw('DATE_FORMAT(created_at,\'%Y%m%d\')=\'' . Carbon::now()->format('%Y%m%d') . '\'')->count();

        return view('system.index',compact(['totalsell','totalamount','totalbox','currentbox']));
    }
}
